﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ButtonBasic : MonoBehaviour
{
    public List<GameObject> charactors;
    public bool state = false;
    protected new SpriteRenderer renderer;
    protected Sprite switchOff;
    protected Sprite switchOn;
    [System.Serializable]
    public class DoorBehavior
    {
        public Door door;
        public bool switchOn=true;
    }
    public List<DoorBehavior> doors;
    protected virtual void AfterSwitchChanged()
    {
        if (state)
        {
            renderer.sprite = switchOn;
        }
        else
        {
            renderer.sprite = switchOff;
        }
        foreach (DoorBehavior item in doors)
        {
            item.door.Receiver(this,!(item.switchOn ^ state));
        }
    }
    protected virtual void Start()
    {
        switchOff = Resources.Load<Sprite>("SwitchOff");
        switchOn = Resources.Load<Sprite>("SwitchOn");
        renderer = GetComponent<SpriteRenderer>();
    }
}
